Repository navigation
perf(map): eliminate redundant PNG serialization in Q10 rendering pipeline - #973
Draft
allenporter wants to merge 5 commits into
Draft
allenporter wants to merge 5 commits into
allenporter wants to merge 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Benchmark coverage and percentile reporting need correction before approval.
Review effort: Lite
Findings: 2
Open (2)
What changed in this PR
Optimizes Q10 map rendering by deferring PNG serialization until composition completes, while preserving existing parsing APIs.
Changes:
- Adds PNG-free
MapDatarendering. - Serializes composed images once.
- Optimizes room-color lookup.
- Adds map benchmarks and profiling support.
| File | Summary |
|---|---|
tests/map/test_benchmarks.py |
Adds map benchmarks; composite coverage does not exercise overlays, and the reported P95 calculation is incorrect. |
roborock/map/room_colors.py |
Adds lookup-table-based room color resolution. |
roborock/map/b01_q10_render.py |
Defers PNG serialization in the rendering pipeline. |
roborock/map/b01_q10_map_parser.py |
Separates image construction from PNG encoding while preserving compatibility. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| """Benchmark Q10 composite rendering on a realistic 200x200 4-room floorplan.""" | ||
| packet = _build_synthetic_q10_grid(200, 200) | ||
| parser = B01Q10MapParser() | ||
| result = benchmark(parser.parse_packet, packet) |
| min_ms = timings[0] | ||
| mean_ms = sum(timings) / len(timings) | ||
| med_ms = timings[len(timings) // 2] | ||
| p95_ms = timings[int(len(timings) * 0.95)] |
allenporter
marked this pull request as draft
September 28, 2026 03:46
allenporter
force-pushed
the
perf-q10-render-pipeline
branch
2 times, most recently
from
September 28, 2026 05:04
65d5c60 to
4b9b409
Compare
allenporter
force-pushed
the
perf-q10-render-pipeline
branch
from
October 4, 2026 22:40
4b9b409 to
fc6c0fd
Compare
allenporter
force-pushed
the
perf-q10-render-pipeline
branch
from
October 5, 2026 14:17
fc6c0fd to
7c59a0b
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
In
render_q10_map, the base packet was previously rendered to PNG bytes viaparsed_from_packet. Then, whenever the map contained drawables (charger, trace path, virtual walls, or no-go zones—which is almost always true),_draw_map_contentre-serialized the image to PNG bytes a second time, discarding the first PNG bytes.This change:
B01Q10MapParser.map_data_from_packet(packet)returningMapDatawith the rendered baseImagewithout performing premature PNG encoding.render_q10_map, defers PNG serialization to the end of the pipeline so that images are encoded exactly once.parsed_from_packetfully backward-compatible for existing callers.Note: Stacked on top of #972, #971, and #970.
Performance Impact
render_q10_mapwith drawables (200x200 grid + trace session): 44.59 msImage.saveinvocations on every map update.Verification
uv run pytest tests/map/).